<template>
  <div class="app-container">
    <el-row>
      <router-link
        :to="'/core/integral-grade/create'"
        style="margin-right: 5px"
      >
        <el-button type="primary" icon="el-icon-plus">新增</el-button>
      </router-link>
    </el-row>

    <el-table :data="list" border stripe>
      <el-table-column type="index" width="100" />
      <el-table-column prop="borrowAmount" label="借款额度" />
      <el-table-column prop="integralStart" label="积分区间开始" />
      <el-table-column prop="integralEnd" label="积分区间结束" />
      <el-table-column fixed="right" label="操作" width="180">
        <template slot-scope="scop">
          <router-link
            :to="'/core/integral-grade/edit/' + scop.row.id"
            style="margin-right: 5px"
          >
            <el-button type="primary" size="small" icon="el-icon-edit"
              >编辑</el-button
            >
          </router-link>
          <el-button
            @click="removeById(scop.row.id)"
            type="danger"
            size="small"
            icon="el-icon-delete"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import integralGradeApi from "@/api/core/integral-grade";
export default {
  data() {
    return {
      list: [], //数据列表
    };
  },

  created() {
    this.initData();
  },
  methods: {
    initData() {
      //调用API
      integralGradeApi.list().then((response) => {
        this.list = response.data.list;
      });
    },
    removeById(id) {
      this.$confirm("此操作将永久删除该记录，是否继续？", "提示", {
        confirmButton: "确定",
        cancelButton: "取消",
        type: "warning",
      }).then(() =>
        integralGradeApi.removeById(id).then((response) => {
          this.$message.success(response.message);
          this.initData();
        })
      );
    },
  },
};
</script>
